﻿using System;
using MaLu.Common;
using MaLu.Data;
using System.Data;

namespace MaluJg.web.HonestRisk
{
    public partial class HDetail : HPage
    {
        protected Guid RecordID
        {
            get
            {
                Guid gd = Guid.NewGuid();
                if (Request["ID"] != null)
                    gd = new Guid(Request["ID"]);
                else
                {
                    if (ViewState["ID"] != null)
                        gd = (Guid)ViewState["ID"];


                }
                if (ViewState["ID"] == null)
                    ViewState["ID"] = gd;
                return gd;
            }
            set
            {
                ViewState["ID"] = value;
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "风险防范监管详细";
            this.UseTabber = true;
            if (!IsPostBack)
            {
               BindData();
            }
        }
        private void BindData()
        {
            DataTable dt = SqlHelper.Instance.ExecuteDataTable(Provider, "select * from [HRisk]  where id ='" + RecordID + "'");
            if (dt.Rows.Count > 0)
            {
                
               
                DataRow dr = dt.Rows[0];

                lbDept.Text = dr["Dept"].ToString().Replace("''", "'");
                lbPosition.Text = dr["Position"].ToString().Replace("''", "'");
                lbResponsibilities.Text = dr["Responsibilities"].ToString().Replace("''", "'");
                lbPatentRisk.Text = dr["PatentRisk"].ToString().Replace("''", "'");
                lbLevel.Text = dr["RiskLevel"].ToString().Replace("''", "'");
                lbPrecautions.Text = dr["Precautions"].ToString().Replace("''", "'");
                lbOthers.Text = dr["Others"].ToString().Replace("''", "'");
                lbWritor.Text = dr["Writor"].ToString().Replace("''", "'");
                lbWriteTime.Text = dr["WriteTime"].ToString().Replace("''", "'");            
            }

         

        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            string sql = string.Format("delete from [HRisk] where id in ('{0}');", RecordID);

            SqlHelper.Instance.ExecuteNonQuery(Provider, sql);
            ClientScript.RegisterStartupScript(this.GetType(), "Delete", "<script>parent.location.href = parent.location.href</script>");
        }

    }
}
